﻿import 'package:flutter/material.dart';

import 'scroll_list_controller.dart';
import 'package:test_app/core/base/base/base_view.dart';
import 'package:test_app/weigets/refreshable_list/index.dart';
import 'package:test_app/core/design_system/extensions/extensions.dart';

typedef OnTapWithCtx = VoidCallback? Function(BuildContext context);

class ScrollListView extends BaseView<ScrollListController> {
  const ScrollListView({super.key});

  @override
  String? get navTitle => "滚动列表";

  @override
  Widget body() {
    return [
          [
            Text('点击刷新').size(150, 80).backgroundColor(Colors.black45).animatedTapScale(() {
              controller.refreshList();
            }),
            Text('侧边2'),
          ].toColumn().backgroundColor(Colors.amber),
          Expanded(
            child: RefreshableList<Item>(
              controller: controller.refreshController,
              fetchData: controller.fetchData,
              pageSize: 8,
              itemBuilder: (item) {
                return [
                  Text('1111-${item.id}'),
                  Text('2222')
                ].toColumn(spacing: 10)
                    .padAll(20)
                    .backgroundColor(Colors.amberAccent)
                    .padAll(5);
              },
              emptyWidget: const Text('没有数据哦~').center(),
            ),
          ),
        ]
        .toRow(mainAxisAlignment: MainAxisAlignment.center)
        .backgroundColor(Colors.white54);
  }
}
